package com._51doit.pool;

import com.mchange.v2.c3p0.ComboPooledDataSource;
import org.apache.commons.dbutils.QueryRunner;

import java.sql.SQLException;

/**
 * @Date 2021/8/24
 * @Created by HANGGE
 * @Description TODO
 */
public class TestPool {

    public static void main(String[] args) throws Exception {



    }

    private static void deleteData() throws SQLException {
        QueryRunner runner = getRunner();
        runner.update("delete from user where uid = ?" , 4) ;
    }

    private static void updateData() throws SQLException {
        QueryRunner runner = getRunner();
        runner.update("update user set  name = ? where uid = ?" ,  "小刘刘",1) ;
    }

    private static void insertData() throws SQLException {
        QueryRunner runner = getRunner();
        runner.update("insert into user values(?,?)", 4, "小源");
    }

    private static QueryRunner getRunner() {
        ComboPooledDataSource dataSource = new ComboPooledDataSource();
        QueryRunner runner = new QueryRunner(dataSource);
        return  runner ;
    }


}
